package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 会话事件通知状态枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum SessionEventNotificationStatus implements BaseEnum {
    /** 不需要通知 */
    NOT_REQUIRED("NOT_REQUIRED", "不需要通知"),
    /** 待通知 */
    PENDING("PENDING", "待通知"),
    /** 通知中 */
    IN_PROGRESS("IN_PROGRESS", "通知中"),
    /** 已通知 */
    NOTIFIED("NOTIFIED", "已通知"),
    /** 通知失败 */
    FAILED("FAILED", "通知失败"),
    /** 已取消 */
    CANCELLED("CANCELLED", "已取消");

    private final String code;
    private final String description;

    SessionEventNotificationStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static SessionEventNotificationStatus fromCode(String code) {
        for (SessionEventNotificationStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的会话事件通知状态代码: " + code);
    }

    public static SessionEventNotificationStatus fromDescription(String description) {
        for (SessionEventNotificationStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的会话事件通知状态描述: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}